home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / Sentry.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  5.6 KB  |  169 lines

  1. UIFIELDS
  2. {
  3. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  4. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  5. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  6. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  7. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  8. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  9. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  10.                                                     // and other things.  It indicates a general level of combat experience.
  11. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?        
  12. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  13. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  14.  
  15. }
  16.  
  17. //------------------------------------------------------------------
  18. // NOTE: The fsm name below MUST be changed in order for the
  19. // script to be considered a unique entity!
  20.  
  21. fsm Generic_Sentry : integer;
  22.  
  23.  
  24. //------------------------------------------------------------------
  25.  
  26. // Generic_Sentry:
  27. //   Stands still.  Moves to attack anything that comes near.
  28. //
  29. //------------------------------------------------------------------
  30.  
  31.  
  32.  
  33. //------------------------------------------------------------------
  34. //     Constants
  35. //------------------------------------------------------------------
  36.  
  37.     const
  38.         #include_ <content\ABLScripts\mwconst.abi>
  39.  
  40. //------------------------------------------------------------------
  41. //     Types
  42. //------------------------------------------------------------------
  43.  
  44.     type
  45.         #include_ <content\ABLScripts\mwtype.abi>
  46.     
  47.  
  48. //------------------------------------------------------------------
  49. //     Variables
  50. //------------------------------------------------------------------
  51.  
  52.     var
  53.         static integer            attackRange;        // At what range do I start shooting?
  54.         static integer            withdrawRange;        // At what range do I withdraw from combat completely?
  55.  
  56.         static integer            piloting;            // Piloting skill
  57.         static integer            gunnery;            // Gunnery skill/chance to hit
  58.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  59.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  60.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  61.                                                     // and other things.  It indicates a general level of combat experience.
  62.         static integer            attackThrottle;        // My attack throttle
  63.         static integer            findTypes;            // What kind of enemies to look for
  64.  
  65.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  66.  
  67.         static integer             attackSound;        // The attack sound I play when I first attack
  68.         static integer             deathSound;            // The sound I play when I die
  69.         
  70.         static integer            mood;                // My default mood.
  71.  
  72.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  73.  
  74. //------------------------------------------------------------------
  75. //     Init: my initialization function
  76. //------------------------------------------------------------------
  77.  
  78. function Init;
  79.     code
  80.     
  81.         // Variables set by editor
  82.         attackRange        = <attackRange>;
  83.         withdrawRange    = <withdrawRange>;
  84.         takeOffDistance    = <takeOffDistance>;
  85.          piloting        = <piloting>;
  86.         gunnery            = <gunnery>;
  87.         minDelay        = <minDelay>;
  88.         maxDelay        = <maxDelay>;
  89.         eliteLevel        = <eliteLevel>;
  90.         isShotRadius    = <isShotRadius>;
  91.     attackThrottle    = <attackThrottle>;
  92.  
  93.  
  94.  
  95.         attackSound        = -1; // no sound
  96.         deathSound        = -1; // no sound
  97.         mood            = NEUTRAL_START;
  98.         findTypes        = FT_DEFAULT;
  99.  
  100. endfunction;
  101.  
  102. //------------------------------------------------------------------
  103. //    StartState: my initial state
  104. //------------------------------------------------------------------
  105.  
  106. state StartState;
  107.  
  108.     code
  109.         SetFiringDelay            (ME,minDelay,maxDelay);
  110.         SetIgnoreFriendlyFire    (ME,true);
  111.         SetIsShotRadius            (ME,isShotRadius);
  112.         SetEntropyMood            (ME,mood);
  113.         SetCurMood                (ME,mood);
  114.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  115.         SetAttackThrottle        (ME,attackThrottle);
  116.                 
  117.         if (orderTakeOff(takeOffDistance) == true) then
  118.             trans WaitState;
  119.         endif;
  120.  
  121. endstate;
  122.  
  123. //------------------------------------------------------------------
  124. //    WaitState: wait for something to shoot
  125. //------------------------------------------------------------------
  126.  
  127. state WaitState;
  128.     code
  129.         OrderMoveLookOut;
  130.  
  131.         if (FindEnemy(attackRange,findTypes)) then
  132.             trans AttackState;
  133.         endif;        
  134. endstate;
  135.  
  136. //------------------------------------------------------------------
  137. //    AttackState: look for something to shoot
  138. //------------------------------------------------------------------
  139.  
  140. state AttackState;
  141.     code
  142.         if (LeaveAttackState(withdrawRange)) then
  143.             OrderStopAttacking;
  144.             SetTarget(ME,NO_UNIT);
  145.             trans WaitState;
  146.         endif;
  147.  
  148.         OrderAttack(true);
  149.  
  150. endstate;
  151.  
  152. //------------------------------------------------------------------
  153. //    DeadState: OK, I kicked the bucket.
  154. //------------------------------------------------------------------
  155.  
  156. state DeadState;
  157.     code
  158.         if (deathSound <> -1) then    
  159.             PlaySoundOnce(deathSound);
  160.         endif;        
  161.  
  162.         orderDie;
  163.  
  164. endstate;
  165.  
  166.  
  167. endfsm.
  168.  
  169.